Retrieve a string from the list of a combo box.
#Include <GuiCombo.au3>
_GUICtrlComboGetLBText($h_combobox, $i_index, ByRef $s_text)
Parameters
$h_combobox | control id/control hWnd |
$i_index | Specifies the zero-based index of the string to retrieve. |
$s_text | Buffer that receives the string |
Return Value
Success: | Returns is the length of the string in TCHARs, excluding the terminating null character. |
Failure: | Returns $CB_ERR if $i_index does not specify a valid index. |
Remarks
None.
Related
_GUICtrlComboGetLBTextLen
Example
#include <GuiConstants.au3>
#include <GuiCombo.au3>
opt('MustDeclareVars', 1)
Dim $Combo, $Btn_Exit, $Status, $msg, $Btn_Get, $Input_item
GUICreate("ComboBox Get LB Text", 392, 254)
$Combo = GUICtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language|designed|for|automating|the Windows GUI.")
GUICtrlCreateLabel("Enter index number of item:", 65, 112, 130, 20, $SS_RIGHT)
$Input_item = GUICtrlCreateInput("0", 200, 110, 50, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_item, 2)
$Btn_Get = GUICtrlCreateButton("Get Text", 150, 140, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUICtrlSetData($Status, "Items: " & _GUICtrlComboGetCount ($Combo))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
Local $s_text
Local $i_count = _GUICtrlComboGetLBText ($Combo, Int(GUICtrlRead($Input_item)), $s_text)
If ($i_count == $CB_ERR) Then
GUICtrlSetData($Status, "Invalid Index: " & GUICtrlRead($Input_item))
Else
GUICtrlSetData($Status, "Len: " & $i_count & ", Index: " & GUICtrlRead($Input_item) & " = " & $s_text)
EndIf
EndSelect
WEnd
Exit